﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/AdminMaster.Master" AutoEventWireup="true" CodeBehind="user.aspx.cs" Inherits="ShowRoom.admin.user" %>


<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<script src="js/jsPowerUser.js" type="text/javascript"></script>
<script src="../pub/js/jquery.js" type="text/javascript"></script>
<div style="width:100%;text-align:center;color:#C794BA;font-weight:bold;margin-bottom:10px;padding-top:15px;"><asp:Label ID="lblTil" runat="server" Text="QUẢN LÝ THÀNH VIÊN"></asp:Label></div>
    <table id="tbl" runat="server" width="100%" style="height: 40px; border-color: #E1E1E1;
        border-collapse: collapse;" border="1" cellpadding="1" cellspacing="2">
        <tr>            
            <td style="width: 10%;border-right:1px solid #E1E1E1;text-align:center" align="center">
                <asp:Label ID="lblName" runat="server" Text="Email "></asp:Label>:
            </td>
            <td style="width: 60%;text-align:center;border-right:1px solid #E1E1E1">
                <asp:TextBox ID="txtEmail" runat="server"  CssClass="cssTextBox" Width="98%"></asp:TextBox>
            </td>
            <td style="width: 10%;border-right:1px solid #E1E1E1;text-align:center">
                <asp:ImageButton ID="imgSerach" runat="server" Width="50px" 
                    ImageUrl="img/btnSear.png" onclick="imgSerach_Click" />
            </td>
        </tr>
       
    </table>
    <table border="0" cellpadding="0" cellspacing="0" width="100%" style="margin-top:15px">
        <tr>
            <td align="left">
              
            </td> 
            <td align="right">              
                <a style="cursor:pointer" onclick="AddUserAdmin();">Thêm mới user</a>
                
            </td>
        </tr>
    </table>
    
    <div style="width: 100%; float: left; margin-top: 10px;">
        <asp:GridView ID="gvUser" runat="server" Width="100%" BorderWidth="1px" 
            BorderColor="#CCCCCC" AutoGenerateColumns="false" DataKeyNames="user_id" 
            onrowdatabound="gvUser_RowDataBound" >
            <HeaderStyle BackColor="#E1E1E1" BorderWidth="1px" BorderColor="#CCCCCC" Height="33px" Font-Bold="True" ForeColor="black" />
            <EditRowStyle BorderColor="Silver" BorderWidth="1px" Height="25px" />
            <AlternatingRowStyle BorderColor="" BorderWidth="1px"/>
            <RowStyle BorderColor="#E1E1E1" BorderWidth="1px" Height="25px" BackColor="white" />
            <EmptyDataRowStyle BorderColor="Silver" BorderWidth="1px" />
            <PagerStyle BorderStyle="None"></PagerStyle>
            <PagerSettings Visible="false" />
            <Columns>
                <asp:TemplateField HeaderText="stt" ItemStyle-HorizontalAlign="center" ItemStyle-Width="7%" HeaderStyle-Width="7%">
                    <ItemTemplate>
                        <%# Container.DataItemIndex + 1 %>
                    </ItemTemplate>                           
                </asp:TemplateField>                                                
                  <asp:TemplateField HeaderText="họ tên" ItemStyle-Height="30px" ItemStyle-BorderWidth="1px" ItemStyle-BorderColor="#E1E1E1"  ItemStyle-HorizontalAlign="Center"> 
                     <ItemTemplate>                                         
                         <asp:Label ID="lblhoten" runat="server" Text='<%# Bind("name") %>'></asp:Label>                                              
                    </ItemTemplate>
                </asp:TemplateField>
                  <asp:TemplateField HeaderText="user_name"  ItemStyle-BorderWidth="1px" ItemStyle-BorderColor="#E1E1E1"  ItemStyle-HorizontalAlign="Center"> 
                     <ItemTemplate >                                         
                         <asp:Label ID="lbluser_name" runat="server" Text='<%# Bind("username") %>' ></asp:Label>                                              
                    </ItemTemplate>
                </asp:TemplateField>                                      
                 <asp:TemplateField HeaderText="email"  ItemStyle-BorderWidth="1px" ItemStyle-BorderColor="#E1E1E1" ItemStyle-HorizontalAlign="Center"> 
                     <ItemTemplate >                                         
                         <asp:Label ID="lblsoluong" runat="server" Text='<%# Bind("email") %>' ></asp:Label>                                              
                    </ItemTemplate>
                </asp:TemplateField>
                
                <asp:TemplateField HeaderText="phone"  ItemStyle-BorderWidth="1px" ItemStyle-BorderColor="#E1E1E1"  ItemStyle-HorizontalAlign="Center"> 
                     <ItemTemplate >                                         
                         <asp:Label ID="lblphone" runat="server" Text='<%# Bind("telephone") %>' ></asp:Label>                                              
                    </ItemTemplate>
                </asp:TemplateField>
                
                <asp:TemplateField HeaderText="ngày thêm" ItemStyle-BorderWidth="1px" ItemStyle-BorderColor="#E1E1E1"  ItemStyle-HorizontalAlign="Center"> 
                     <ItemTemplate >                                         
                         <asp:Label ID="lbldateadd" runat="server" Text='<%# Bind("cday") %>' ></asp:Label>                                              
                    </ItemTemplate>
                </asp:TemplateField>          
                                                 
                 <asp:TemplateField HeaderText="giới tính"  ItemStyle-BorderWidth="1px" ItemStyle-BorderColor="#E1E1E1" ItemStyle-HorizontalAlign="Center"> 
                     <ItemTemplate >                                         
                         <asp:Label ID="lblsex" runat="server" Text='<%# Bind("sex") %>' ></asp:Label>                                              
                    </ItemTemplate>
                </asp:TemplateField>  
                <asp:TemplateField HeaderText="active"  ItemStyle-BorderWidth="1px" ItemStyle-BorderColor="#E1E1E1" ItemStyle-HorizontalAlign="Center"> 
                     <ItemTemplate >                                         
                         <asp:Label ID="lblactive" runat="server" Text='<%# Bind("active") %>' ></asp:Label>                                              
                    </ItemTemplate>
                </asp:TemplateField> 
                  <asp:TemplateField HeaderText="cấp quyền"  ItemStyle-BorderWidth="1px" ItemStyle-BorderColor="#E1E1E1" ItemStyle-HorizontalAlign="Center"> 
                     <ItemTemplate > 
                         <a onclick="ViewPowerUser(this,'<%#Eval("user_id")%>');"  style="border-width: 0px; border-style: none; cursor: pointer">                                        
                            <asp:Image ID="imgPower" runat="server" Width="24px" ImageUrl="img/Boss.gif" />       
                         </a>                                
                    </ItemTemplate>
                </asp:TemplateField> 
                 <asp:TemplateField HeaderText="quản lý" ItemStyle-BorderWidth="1px" ItemStyle-BorderColor="#E1E1E1"  ItemStyle-Wrap="false" HeaderStyle-Wrap="false" ItemStyle-HorizontalAlign="center" HeaderStyle-HorizontalAlign="center" ItemStyle-Width="10%" HeaderStyle-Width="10%">
                      <ItemTemplate>                                                
                         <asp:Image ID="imgEdit" runat="server" ImageUrl="img/modify.gif" /> 
                          <asp:Image ID="imgDelete" runat="server" ImageUrl="img/delete.gif" />      
                            <asp:Literal ID="litView" runat="server" Text="</td></tr><tr style='display:none'><td colspan='10' align='center'>"></asp:Literal>                                                                                 
                     </ItemTemplate>             
                 </asp:TemplateField>
            </Columns>
        </asp:GridView>
    </div>
    <input id="txtDeleteUser" type="hidden" name="txtDeleteUser" runat="server" />
    <script type="text/javascript">
        function AddUserAdmin() {
            window.open("AddUser.aspx?", null, 'status=no, scroll=no, toolbar=no,width=650px,height=400px,Left=250px,Top=150px');
        }
        function EditUserAdmin(user_id) {
            window.open("AddUser.aspx?user_id=" + user_id, null, 'status=no, scroll=no, toolbar=no,width=650px,height=400px,Left=250px,Top=150px');
        }
        function setBk(itemGrid) {
            currentColor = itemGrid.style.backgroundColor;
            itemGrid.style.backgroundColor = "#FFFFCC";
        }

        function setBkOut(itemGrid) {
            itemGrid.style.backgroundColor = currentColor;
        }
        function CheckPowerUser(user_id, mn_id, chk_view, chk_add, chk_edit, chk_del, myType) {
          
            if (myType == "0") {
                if (chk_view == "Y")
                    chk_view = "";
                else
                    chk_view = "Y";
            }
           
            if (myType == "1") {
                if (chk_add == "Y")
                    chk_add = "";
                else
                    chk_add = "Y";
            }
            if (myType == "2") {
                if (chk_edit == "Y")
                    chk_edit = "";
                else
                    chk_edit = "Y";
            }
            if (myType == "3") {
                if (chk_del == "Y")
                    chk_del = "";
                else
                    chk_del = "Y";
            }
            $.ajax({
                type: "GET",
                url: "/../../pub/control/AjaxJquery.aspx?&type=inspoweruser&mn_id_d=" + user_id + "&user_id=" + user_id + "&mn_id=" + mn_id + "&chk_view=" + chk_view + "&chk_add=" + chk_add + "&chk_edit=" + chk_edit + "&chk_del=" + chk_del + "&Typek=" + myType,
                success: function (resp) {
                    alert('Cấp quyền thành công !');
                    form1.submit();
                }
            });

        }
        //xóa menu
        function CheckDeleteUser(user_id) {
            var result = confirm("Xóa user này đồng nghĩa xóa hết quyền hạn ? ");
            if (result == true) {
                var txt = document.getElementById("<%=txtDeleteUser.ClientID%>");
                txt.value = "";
                txt.value = user_id;
                form1.submit();
            }
            else {
                return false;
            }
        }
    </script>
</asp:Content>
